// pages/index/index.js
const app = getApp()
const { indexFresh  } = require('../../../utils/api.js')
Page({
  /**
   * 页面的初始数据
   */
 data:{
  navBarHeight: app.globalData.navBarHeight,
  list:[]
 },
 todetail: function(e){
   let projectId = e.target.dataset.id
  wx.navigateTo({
    url: '../detail/detail?projectId='+projectId,
  })
 },
 value(e){
  let value = e.detail.value
  this.setData({
    list:value
  })
 },
 length(e){
  // console.log('length',e.detail.length);
  let length = e.detail.length
  if(length === 0){
    this.onLoad()
  }
 },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    indexFresh().then((res)=>{
      this.setData({
        list:res.data
      })
    })
  },
})
